package com.ocom.xfrecode.controller;

import com.ocom.common.constant.UnifiendPayUrl;
import com.ocom.common.request.xfrecde.GetGroupDataRequest;
import com.ocom.common.resp.Result;
import com.ocom.common.utils.ResultUtil;
import com.ocom.xfrecode.service.XfRecordService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @Description: TODO
 * @Author: 朱晖
 * @Date: 2023/4/7
 **/
@Slf4j
@RestController
public class ConRecController {

	@Autowired
	private XfRecordService xfRecordService;


	@PostMapping(UnifiendPayUrl.URL_getConsRecNum)
	public Result getConsRecNum(Long beginComId, Long endComId ,String month){
		return ResultUtil.success(xfRecordService.getXfCountByComId(beginComId,endComId,month));
	}

	@PostMapping(UnifiendPayUrl.URL_getSubDbConsRecNum)
	public Result getSubDbConsRecNum(Long beginComId, Long endComId ,String month){
		Map<String,Object> resmap = new HashMap<>();
		resmap.put("xfRecNum",xfRecordService.getXfCount(beginComId,endComId,month));
		return ResultUtil.success(resmap);
	}

	@PostMapping(UnifiendPayUrl.URL_getConsMonthData)
	public Result getConsMonthData(Long comId,String beginMonth, String endMonth ){
		return xfRecordService.getXfCount(comId,beginMonth,endMonth);
	}

	@PostMapping(UnifiendPayUrl.URL_getSubDbConsMonthData)
	public Result getSubDbConsMonthData(Long beginComId, Long endComId ,String beginMonth, String endMonth ){
		return xfRecordService.getXfCount(beginComId,endComId,beginMonth,endMonth);
	}


	@PostMapping(UnifiendPayUrl.URL_getChannelData)
	public Result getChannelData(Long comId,String payChannelNo, String startTime ,String endTime){
		return xfRecordService.getChannelData(comId,payChannelNo,startTime,endTime);
	}

	@PostMapping(UnifiendPayUrl.URL_getGroupData)
	public Result getGroupData(@RequestBody GetGroupDataRequest request){
		return xfRecordService.getGroupData(request);
	}


}
